/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.protocol.passive;

import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol;
import lombok.AccessLevel;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import lombok.experimental.FieldDefaults;
import lombok.experimental.SuperBuilder;

import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.BCD;
import static info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocol.DianlanProtocolDataType.BIT;

/**
 * <b>(DianlanChargingBmsSuspend)</b>
 * <p>
 * 充电阶段 BMS 中止,GBT-27930 充电桩与 BMS 充电阶段 BMS 中止报文
 * 帧类型码 0x1D(29)
 * 序列号域 0018
 * 数据长度 32
 * 帧校验域 8445
 *
 * @author Peigen
 * @version 1.0.0
 * @since 2022/8/19
 */
@SuperBuilder
@Data
@NoArgsConstructor
@AllArgsConstructor
@FieldDefaults(level = AccessLevel.PRIVATE)
@Accessors(chain = true)
public class DianlanChargingBmsSuspend {
    /** 交易流水号 */
    @DianlanProtocol(length = 16, start = 0, end = 16, dataType = BCD)
    String transNo;
    /** 桩编码 */
    @DianlanProtocol(length = 7, start = 16, end = 23, dataType = BCD)
    String stubNo;
    /** 充电枪号 */
    @DianlanProtocol(length = 1, start = 23, end = 24, dataType = BCD)
    String chargingPortNo;
    /**
     * BMS 中止充电原因
     * <p>
     * 1-2 位——所需求的 SOC 目标值
     * 3-4 位——达到总电压的设定值
     * 5-6 位——达到单体电压设定值
     * 7-8 位——充电机主动中止
     */
    @DianlanProtocol(length = 1, start = 24, end = 25, dataType = BIT, dataTypeClass = "DianlanBmsSuspendReasonBits")
    String bmsSuspendReason;
    /**
     * BMS 中止充电故障原因
     * <p>
     * 1-2 位——绝缘故障
     * 3-4 位——输出连接器过温故障
     * 5-6 位——BMS 元件、输出连接器过温
     * 7-8 位——充电连接器故障
     * 9-10 位——电池组温度过高故障
     * 11-12 位——高压继电器故障
     * 13 位-14 位——检测点 2 电压检测故障
     * 15-16 位——其他故障
     */
    @DianlanProtocol(length = 2, start = 25, end = 27, dataType = BIT, dataTypeClass = "DianlanBmsSuspendMalfunctionReasonBits")
    String bmsSuspendMalfunctionReason;
    /**
     * BMS 中止充电错误原因
     * <p>
     * 1-2 位——电流过大
     * 3-4 位——电压异常
     * 5-8 位——预留位
     */
    @DianlanProtocol(length = 1, start = 27, end = 28, dataType = BIT, dataTypeClass = "DianlanBmsSuspendFailureReasonBits")
    String bmsSuspendFailureReason;
}